home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / ColorSync™ 1.0.3 / Interfaces / PInterfaces / CMApplication.p next >
Encoding:
Text File  |  1993-07-19  |  8.3 KB  |  333 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        CMApplication.p
  3.  
  4.     Contains:    Header for Color Matching aware applications
  5.  
  6.     Written by:    Tom Mohr
  7.  
  8.     Copyright:    © 1992-93 by Apple Computer, Inc., all rights reserved.
  9.  
  10.  
  11. }
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17. {$IFC NOT UsingIncludes}
  18.  UNIT CMApplication;
  19.  INTERFACE
  20. {$ENDC}
  21.  
  22. {$IFC UNDEFINED UsingCMApplication}
  23. {$SETC UsingCMApplication := 1}
  24.  
  25. {$I+}
  26. {$SETC CMApplicationIncludes := UsingIncludes}
  27. {$SETC UsingIncludes := 1}
  28.  
  29. {$IFC UNDEFINED UsingTypes}
  30. {$I $$Shell(PInterfaces)Types.p}
  31. {$ENDC}
  32.  
  33. {$IFC UNDEFINED UsingQuickdraw}
  34. {$I $$Shell(PInterfaces)Quickdraw.p}
  35. {$ENDC}
  36.  
  37. {$IFC UNDEFINED UsingPrinting}
  38. {$I $$Shell(PInterfaces)Printing.p}
  39. {$ENDC}
  40.  
  41. {$SETC UsingIncludes := CMApplicationIncludes}
  42.  
  43.  
  44. CONST
  45.  
  46. gestaltColorMatchingVersion    = 'cmtc';
  47. CMTrap = $ABEE;
  48.  
  49. { PicComments }
  50. CMBeginProfile = 220;
  51. CMEndProfile = 221;
  52. CMEnableMatching = 222;
  53. CMDisableMatching = 223;
  54.  
  55. { Defines for fieldMask in profile search record }
  56. kMatchCMMType = $00000001;
  57. kMatchApplProfileVersion = $00000002;
  58. kMatchDataType = $00000004;
  59. kMatchDeviceType = $00000008;
  60. kMatchDeviceManufacturer = $00000010;
  61. kMatchDeviceModel = $00000020;
  62. kMatchDeviceAttributes = $00000040;
  63. kMatchFlags = $00000080;
  64. kMatchOptions = $00000100;
  65. kMatchWhite = $00000200;
  66. kMatchBlack = $00000400;
  67.  
  68. { Profile Header version }
  69. kCMApplProfileVersion = $0100;
  70.  
  71. { Data types }
  72. rgbData = 'RGB ';
  73. cmykData = 'CMYK';
  74. grayData = 'GRAY';
  75. xyzData = 'XYZ ';
  76.  
  77. { Device types }
  78. monitorDevice = 'mntr';
  79. scannerDevice = 'scnr';
  80. printerDevice = 'prtr';
  81. qdSystemDevice = 'sys ';
  82. qdGDevice = 'gdev';
  83.  
  84. { Profile flags }
  85. CMNativeMatchingPreferred = $00000001;            { Default to native not preferred }
  86. CMTurnOffCache = $00000002;                        { Default to turn on CMM cache }
  87.  
  88. { Profile options }
  89. CMPerceptualMatch = $00000000;                    { Default. For photographic images }
  90. CMColorimetricMatch = $00000001;                { Exact matching when possible }
  91. CMSaturationMatch = $00000002;                    { For solid colors }
  92.  
  93. { ColorSync result codes }
  94. CMNoError = 0;
  95. CMProfileError = -170;
  96. CMMethodError = -171;
  97. CMMemFullError = -172;
  98. CMUnimplementedError = -173;
  99. CMParamError = -174;
  100. CMMethodNotFound = -175;                        { CMM not present }
  101. CMProfileNotFound = -176;                        { Responder error }
  102. CMProfilesIdentical = -177;                        { Profiles the same }
  103. CMCantConcatenateError = -178;                    { Profile can't be concatenated }
  104. CMCantXYZ = -179;                                { CMM cant handle XYZ space }
  105. CMCantDeleteProfile = -180;                        { Responder error }
  106. CMUnsupportedDataType = -181;                    { Responder error }
  107. CMNoCurrentProfile = -182;                        { Responder error }
  108.  
  109. grayResponse = 0;
  110. redResponse = 1;
  111. greenResponse = 2;
  112. blueResponse = 3;
  113. cyanResponse = 4;
  114. magentaResponse = 5;
  115. yellowResponse = 6;
  116. ucrResponse = 7;
  117. bgResponse = 8;
  118. onePlusLastResponse = 9;
  119.  
  120. { Printing Stuff that will be moved later }
  121. enableColorMatchingOp = 12;
  122. registerProfileOp = 13;
  123.  
  124.  
  125. TYPE
  126.  
  127. CMMatchFlag = LONGINT;
  128. CMMatchOption = LONGINT;
  129. CMMatchRef = LONGINT;
  130. CWorld = LONGINT;
  131. CMError = LONGINT;
  132. CMResponseData = INTEGER;
  133.  
  134. CMGamutResult = ^LONGINT;                        { Pointer to bit array }
  135.  
  136. PixMapCallBackProcPtr = ProcPtr;                { FUNCTION CallBack(progress: LONGINT; refCon: LONGINT): BOOLEAN; }
  137.  
  138.  
  139. XYZColor = RECORD
  140.     X: INTEGER;                                    { 1.15 bit unsigned fixed point }
  141.     Y: INTEGER;
  142.     Z: INTEGER;
  143. END;
  144.  
  145.  
  146. CMYKColor = RECORD
  147.     cyan: INTEGER;
  148.     magenta: INTEGER;
  149.     yellow: INTEGER;
  150.     black: INTEGER;
  151. END;
  152.  
  153.  
  154. CMColorList = ^CMColor;
  155. CMColor = RECORD
  156.     CASE INTEGER OF
  157.         1: (rgb: RGBColor);
  158.         2: (xyz: XYZColor);
  159.         3: (cmyk: CMYKColor);
  160. END;
  161.  
  162.  
  163. CMHeader = RECORD
  164.     size: LONGINT;                                { This is the total size of the Profile including custom data }
  165.     CMMType: OSType;                            { Corresponding CMM }
  166.     applProfileVersion: LONGINT;                { Version of CMProfile format }
  167.     dataType: OSType;                            { rgbData, etc. }
  168.     deviceType: OSType;                            { monitorDevice, etc. }
  169.     deviceManufacturer: OSType;                    { Registered with DTS }
  170.     deviceModel: LONGINT;                        { Specific to Manufacturer }
  171.     deviceAttributes: ARRAY[0..1] OF LONGINT;    { Attributes like paper, ink, etc. }
  172.     profileNameOffset: LONGINT;                    { Offset to profile name from top of data }
  173.     customDataOffset: LONGINT;                    { Offset to custom data from top of data }
  174.     flags: CMMatchFlag;
  175.     options: CMMatchOption;
  176.     white: XYZColor;
  177.     black: XYZColor;
  178. END;
  179.  
  180.  
  181. CMProfileSearchRecordHandle = ^CMProfileSearchRecordPtr;
  182. CMProfileSearchRecordPtr = ^CMProfileSearchRecord;
  183.  
  184. CMProfileSearchRecord = RECORD
  185.     header: CMHeader;
  186.     fieldMask: LONGINT;
  187.     reserved: ARRAY[0..1] OF LONGINT;
  188. END;
  189.  
  190.  
  191. CMProfileChromaticities = RECORD
  192.     red: XYZColor;
  193.     green: XYZColor;
  194.     blue: XYZColor;
  195.     cyan: XYZColor;
  196.     magenta: XYZColor;
  197.     yellow: XYZColor;
  198. END;
  199.  
  200.  
  201. IStringHandle = ^IStringPtr;
  202. IStringPtr = ^IString;
  203.  
  204. IString = RECORD
  205.     theScript: ScriptCode;
  206.     theString: Str63;
  207. END;
  208.  
  209.  
  210. CMProfileResponse = RECORD
  211.     counts: ARRAY[grayResponse..bgResponse] OF INTEGER;
  212.     data: ARRAY[0..0] OF CMResponseData;
  213. END;
  214.  
  215.  
  216. CMProfileHandle = ^CMProfilePtr;
  217. CMProfilePtr = ^CMProfile;
  218.  
  219. CMProfile = RECORD
  220.     header: CMHeader;
  221.     profile: CMProfileChromaticities;
  222.     response: CMProfileResponse;            { Variable size }
  223.     profileName: IString;                    { Variable size }
  224.     customData: ARRAY[0..0] OF INTEGER;        { Optional variable length custom CMM data. Word aligned. }
  225. END;
  226.  
  227.  
  228. { Printing Stuff that will be moved later }
  229. { PrGeneral parameter blocks }
  230.  
  231. TEnableColorMatchingBlk = RECORD
  232.     iOpCode: INTEGER;
  233.     iError: INTEGER;
  234.     lReserved: LONGINT;
  235.     hPrint: THPrint;
  236.     fEnableIt: BOOLEAN;
  237. END;
  238.  
  239.  
  240. TRegisterProfileBlk = RECORD
  241.     iOpCode: INTEGER;
  242.     iError: INTEGER;
  243.     lReserved: LONGINT;
  244.     hPrint: THPrint;
  245.     fRegisterIt: BOOLEAN;
  246. END;
  247.  
  248.  
  249. { High Level Calls }
  250.  
  251. FUNCTION BeginMatching(src: CMProfileHandle; dst: CMProfileHandle; VAR myRef: CMMatchRef): CMError;
  252.     INLINE $203C, $000C, $000A, $ABEE;
  253.  
  254. PROCEDURE EndMatching(myRef: CMMatchRef);
  255.     INLINE $203C, $0004, $000B, $ABEE;
  256.  
  257. FUNCTION GetProfile(deviceType: OSType; refNum: LONGINT; aProfile: CMProfileHandle;
  258.                     VAR returnedProfile: CMProfileHandle): CMError;
  259.     INLINE $203C, $0010, $0005, $ABEE;
  260.  
  261. FUNCTION SetProfile(deviceType: OSType; refNum: LONGINT; newProfile: CMProfileHandle): CMError;
  262.     INLINE $203C, $000C, $0006, $ABEE;
  263.  
  264. FUNCTION SetProfileDescription(deviceType: OSType; refNum: LONGINT; deviceData: UNIV LONGINT;
  265.                                hProfile: CMProfileHandle): CMError;
  266.     INLINE $203C, $0010, $0010, $ABEE;
  267.  
  268. FUNCTION GetColorSyncFolderSpec(vRefNum: INTEGER; createFolder: BOOLEAN; VAR foundVRefNum: INTEGER;
  269.                                 VAR foundDirID: LONGINT): CMError;
  270.     INLINE $203C, $000C, $0011, $ABEE;
  271.  
  272. FUNCTION GetIndexedProfile(deviceType: OSType; refNum: LONGINT; search: CMProfileSearchRecordHandle;
  273.                            VAR returnProfile: CMProfileHandle; VAR index: LONGINT): CMError;
  274.     INLINE $203C, $0014, $0012, $ABEE;
  275.  
  276. FUNCTION DeleteDeviceProfile(deviceType: OSType; refNum: LONGINT; deleteMe: CMProfileHandle): CMError;
  277.     INLINE $203C, $000C, $0013, $ABEE;
  278.  
  279. { Data interchange routines }
  280.  
  281. FUNCTION UseProfile(profile: CMProfileHandle): CMError;
  282.     INLINE $203C, $0004, $0008, $ABEE;
  283.  
  284. PROCEDURE DrawMatchedPicture(myPicture: PicHandle; dst: CMProfileHandle; myRect: Rect);
  285.     INLINE $203C, $000C, $0009, $ABEE;
  286.  
  287. PROCEDURE EnableMatching(enableIt: BOOLEAN);
  288.     INLINE $203C, $0002, $000D, $ABEE;
  289.  
  290. { Profile concatenation }
  291.  
  292. FUNCTION ConcatenateProfiles(thru: CMProfileHandle; dst: CMProfileHandle;
  293.                              VAR newDst: CMProfileHandle): CMError;
  294.     INLINE $203C, $000C, $000C, $ABEE;
  295.  
  296. { Profile manipulation routines }
  297.  
  298. PROCEDURE GetProfileName(myProfile: CMProfileHandle; VAR IStringResult: IString);
  299.     INLINE $203C, $0008, $000E, $ABEE;
  300.  
  301. FUNCTION GetProfileAdditionalDataOffset(myProfile: CMProfileHandle): LONGINT;
  302.     INLINE $203C, $0004, $000F, $ABEE;
  303.  
  304. { Low level color calculation routines }
  305.  
  306. FUNCTION CWNewColorWorld(VAR myCWorld: CWorld; src: CMProfileHandle; dst: CMProfileHandle): CMError;
  307.     INLINE $203C, $000C, $0000, $ABEE;
  308.  
  309. PROCEDURE CWDisposeColorWorld(myCWorld: CWorld);
  310.     INLINE $203C, $0004, $0001, $ABEE;
  311.  
  312. FUNCTION CWMatchColors(myCWorld: CWorld; myColors: CMColorList; count: LONGINT): CMError;
  313.     INLINE $203C, $000C, $0002, $ABEE;
  314.  
  315. FUNCTION CWCheckColors(myCWorld: CWorld; myColors: CMColorList; count: LONGINT;
  316.                        result: CMGamutResult): CMError;
  317.     INLINE $203C, $0010, $0003, $ABEE;
  318.  
  319. FUNCTION CWMatchPixMap(myCWorld: CWorld; myPixMap: PixMap; progressProc: PixMapCallBackProcPtr;
  320.                        refCon: LONGINT): CMError;
  321.     INLINE $203C, $0010, $0004, $ABEE;
  322.  
  323. FUNCTION CWCheckPixMap(myCWorld: CWorld; myPixMap: PixMap; progressProc: PixMapCallBackProcPtr;
  324.                        refCon: LONGINT; VAR resultBitMap: BitMap): CMError;
  325.     INLINE $203C, $0014, $0007, $ABEE;
  326.  
  327.  
  328. {$ENDC UsingCMApplication}
  329.  
  330. {$IFC NOT UsingIncludes}
  331. END.
  332. {$ENDC}
  333.